using System;
using System.Threading.Tasks;

namespace JGSY.CMS.LowCode.Platform.Domain.Interfaces
{
    /// <summary>
    /// 工作单元接口
    /// 提供统一的事务管理和仓储访问
    /// </summary>
    public interface IUnitOfWork : IDisposable
    {
        /// <summary>
        /// 文章仓储
        /// </summary>
        IArticleRepository Articles { get; }

        /// <summary>
        /// 分类仓储
        /// </summary>
        ICategoryRepository Categories { get; }

        /// <summary>
        /// 用户仓储
        /// </summary>
        IUserRepository Users { get; }

        /// <summary>
        /// 角色仓储
        /// </summary>
        IRoleRepository Roles { get; }

        /// <summary>
        /// 部门仓储
        /// </summary>
        IDepartmentRepository Departments { get; }

        /// <summary>
        /// 团队仓储
        /// </summary>
        ITeamRepository Teams { get; }

        /// <summary>
        /// 团队成员仓储
        /// </summary>
        ITeamMemberRepository TeamMembers { get; }

        /// <summary>
        /// 模板仓储
        /// </summary>
        ITemplateRepository Templates { get; }

        /// <summary>
        /// 产品仓储
        /// </summary>
        IProductRepository Products { get; }

        /// <summary>
        /// 内容仓储
        /// </summary>
        IContentRepository Contents { get; }

        /// <summary>
        /// 表单仓储
        /// </summary>
        IFormRepository Forms { get; }

        /// <summary>
        /// 表单字段仓储
        /// </summary>
        IFieldRepository Fields { get; }

        /// <summary>
        /// 表单提交仓储
        /// </summary>
        IFormSubmissionRepository FormSubmissions { get; }

        /// <summary>
        /// 页面仓储
        /// </summary>
        IPageRepository Pages { get; }

        /// <summary>
        /// 媒体文件仓储
        /// </summary>
        IMediaFileRepository MediaFiles { get; }

        /// <summary>
        /// 系统设置仓储
        /// </summary>
        ISystemSettingRepository SystemSettings { get; }

        /// <summary>
        /// 审计日志仓储
        /// </summary>
        IAuditLogRepository AuditLogs { get; }

        /// <summary>
        /// 安全事件仓储
        /// </summary>
        ISecurityEventRepository SecurityEvents { get; }

        /// <summary>
        /// 登录历史仓储
        /// </summary>
        ILoginHistoryRepository LoginHistories { get; }

        /// <summary>
        /// 用户设备仓储
        /// </summary>
        IUserDeviceRepository UserDevices { get; }

        /// <summary>
        /// 双因子认证仓储
        /// </summary>
        ITwoFactorRepository TwoFactors { get; }

        /// <summary>
        /// 风险评估仓储
        /// </summary>
        IRiskAssessmentRepository RiskAssessments { get; }

        /// <summary>
        /// 发布仓储
        /// </summary>
        IPublishRepository Publishes { get; }

        /// <summary>
        /// 工作流仓储
        /// </summary>
        IWorkflowRepository Workflows { get; }

        /// <summary>
        /// 工作流实例仓储
        /// </summary>
        IWorkflowInstanceRepository WorkflowInstances { get; }

        /// <summary>
        /// 工作流任务仓储
        /// </summary>
        IWorkflowTaskRepository WorkflowTasks { get; }

        /// <summary>
        /// 权限仓储
        /// </summary>
        IPermissionRepository Permissions { get; }

        /// <summary>
        /// 用户角色仓储
        /// </summary>
        IUserRoleRepository UserRoles { get; }

        /// <summary>
        /// 开始事务
        /// </summary>
        Task BeginTransactionAsync();

        /// <summary>
        /// 提交事务
        /// </summary>
        Task CommitTransactionAsync();

        /// <summary>
        /// 回滚事务
        /// </summary>
        Task RollbackTransactionAsync();

        /// <summary>
        /// 保存所有更改
        /// </summary>
        Task<int> SaveChangesAsync();

        /// <summary>
        /// 创建保存点
        /// </summary>
        Task CreateSavepointAsync(string name);

        /// <summary>
        /// 回滚到保存点
        /// </summary>
        Task RollbackToSavepointAsync(string name);

        /// <summary>
        /// 释放保存点
        /// </summary>
        Task ReleaseSavepointAsync(string name);
    }
}
